<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    String id=request.getParameter("id");
    String username=request.getParameter("username");
    String password=request.getParameter("password");
    Connection connection=null;
    Statement statement=null;

    try {
        Class.forName("com.mysql.jdbc.Driver");
    }
    catch (ClassNotFoundException e){
        e.printStackTrace();
    }
    try {
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC&characterEncoding=gbk","root","w19971201t");
        statement=connection.createStatement();
        statement.executeUpdate("UPDATE t_user SET username='"+username+"',password='"+password+"'WHERE id="+id+"");
    }
    catch (SQLException e){
        e.printStackTrace();
    }
    finally {
        try{
            connection.close();
            statement.close();
        }
        catch(SQLException e){
            e.printStackTrace();
        }
    }
%>
<script type="text/javascript">
    onload=function () {
        setTimeout(go(),100)
    }
    function go() {
        location.href="http://localhost:8080/userList.jsp"
    }
</script>
</body>
</html>
